package
{
	import com.engine.PowerEngine;
	import com.manager.CarSence;
	import com.manager.CarXmlManager;
	import com.manager.Vision;
	import com.model.CarDataRemote;
	import com.net.Share;
	
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;

//	[SWF(width="1200",height="700", frameRate="60", backgroundColor=0xFFFFFF)]
	[SWF(width="1440",height="700", frameRate="60", backgroundColor=0xFFFFFF)]
	public class Main extends Sprite
	{
		public function Main()
		{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			addEventListener(flash.events.Event.ADDED_TO_STAGE,addToStage);
//			Share.clear();
		}
		
		private function addToStage(e:flash.events.Event):void
		{
			Vision.stage = stage;
//			MouseWheelEnabler.init(this.stage);//禁止浏览器滚轮事件
			removeEventListener(flash.events.Event.ADDED_TO_STAGE,addToStage);
			CarXmlManager.loadCarXml("xml/CarXml.xml",xmlComplete);
			CarDataRemote.start(phpComplete);
		}
		
		private var xmlEnd:Boolean;
		private var phpEnd:Boolean;
		private function xmlComplete():void
		{
			xmlEnd = true;
			initProxies();
		}
		
		private function phpComplete():void
		{
			phpEnd = true;
			initProxies();
		}
		
		private function initProxies():void
		{
			if(xmlEnd && phpEnd)
			PowerEngine.createEngine(GameMain,stage,4,CarSence.start/*,StageBackground*/);
		}

	}
}